import request from "@/utils/request";

const api = {
  createPoster: "/cms/material/poster/create",
  getPosterList: "/cms/material/poster/list",
  getPosterInfo: "/cms/material/poster/detail",
  updatePoster: "/cms/material/poster/update",
  deletePoster: "/cms/material/poster/delete",
  batchCreatePoster: "/cms/material/poster/createBatch",
  updatePosterName: "/cms/material/poster/updateName"
};

export function createPoster(parameter) {
  return request({
    url: api.createPoster,
    method: "put",
    data: parameter
  });
}

export function getPosterList(parameter) {
  return request({
    url: api.getPosterList,
    method: "post",
    data: parameter
  });
}

export function getPosterInfo({ id }) {
  return request({
    url: `${api.getPosterInfo}/${id}`
  });
}

export function updatePoster(parameter) {
  return request({
    url: api.updatePoster,
    method: "post",
    data: parameter
  });
}

export function deletePoster({ id }) {
  return request({
    url: `${api.deletePoster}/${id}`,
    method: "delete"
  });
}

export function batchCreatePoster(parameter) {
  return request({
    url: api.batchCreatePoster,
    method: "put",
    data: parameter
  });
}

export function updatePosterName(parameter) {
  return request({
    url: api.updatePosterName,
    method: "post",
    data: parameter,
    headers: {
      "Content-Type": "application/x-www-form-urlencoded"
    }
  });
}
